﻿'----------------------------------------------
'   
'   Kernel Info:---------------------------
'   Developer:              Joshua Teeter
'   Genesis:                09-02-08
'   Last Update:            09-05-26
'   Origional Version:      0.0.0.0
'   Current Version:        0.0.0.5
'   ---------------------------------------
'   
'   
'   If you modify this code please leave your name in the modified by list seperated by a comma. 
'   Changes are to be denoted in the following manner:
'                                                       * New
'                                                       ^ Updated
'                                                       - Removed
'                                                       + Added Functionality
'                                                       ! Bug unresolved
'                                                       / Bug resolved
'                                                       % Modified but not changed in a noticeable way in terms of functionality
'  
'  Please use the following as a template and copy and paste as a new comment for each modification.
'   
'   Modification Info:---------------------
'   Class Name:             ATEA.vb
'   Modified by:            NULL
'   Last Update:            NULL
'   Current Version:        #.#.#.#
'   Changes:                 NULL
'   ---------------------------------------
'   Modification Info:---------------------
'   Class Name:             ATEA.vb
'   Modified by:            Joshua Teeter
'   Last Update:            09-04-11
'   Current Version:        0.0.0.1
'   Changes:                 / Resolved issue with short names (see frmMain)
'   ---------------------------------------
'   Modification Info:---------------------
'   Class Name:             ATEA.vb
'   Modified by:            Joshua Teeter
'   Last Update:            09-04-23
'   Current Version:        0.0.0.2
'   Changes:                 * Now tells user tomorrows time after application launch time has passed
'                           * Added ability to update shortName on the fly: See updateShortName()
'                             This feature is linked into the "top" sub in ATEAList
'   ---------------------------------------
'   Modification Info:---------------------
'   Class Name:             ATEA.vb
'   Modified by:            Joshua Teeter
'   Last Update:            09-04-23
'   Current Version:        0.0.0.3
'   Changes:                 % Changed the way ATEA makes short names and unified the calling of the sub.
'   ---------------------------------------
'   Modification Info:---------------------
'   Class Name:             ATEA.vb
'   Modified by:            Joshua Teeter
'   Last Update:            09-05-05
'   Current Version:        0.0.0.4
'   Changes:                 * ShortName now provides status update on if the application is enabled for each day.
'   ---------------------------------------
'   Modification Info:---------------------
'   Class Name:             ATEA.vb
'   Modified by:            Joshua Teeter
'   Last Update:            09-06-22
'   Current Version:        0.0.0.5
'   Changes:                 * Added variable to house the "start with windows" status
'   ---------------------------------------
'
'
' ATEA = Application, Time, Enabled, Arguements
'
' This data structure is a middle structure for the application, for a view of how the
' data structure actually works please view the ATEAList class and the SMTWTFS class.
' This only contains the application path, arguements, enabled status, and a pointer to
' a SMTWTFS structure related to the named application. This class is used for every new
' application added to Rocket Launcher.
'
' The short name is generated based on the application name. One should not edit this.
'
'

Public Class ATEA

    Private shortName As String
    Private application As String
    Private arguements As String
    Private time As SMTWTFS
    Private Enabled As Boolean
    Private startup As Boolean ' run at start-up

    '
    ' Provide just the shortname to the calling proceedure 
    '
    Public ReadOnly Property _shortName() As String
        Get
            Return shortName
        End Get
    End Property

    '
    ' Give the calling program the ability to change the application on the fly
    ' 
    Public Property _application() As String
        Get
            Return application
        End Get
        Set(ByVal value As String)
            application = value
            shortName = "temp"
            updateShortName()
            System.GC.Collect()
        End Set
    End Property

    '
    ' Change or get arguements on the fly 
    '
    Public Property _arguements() As String
        Get
            Return arguements
        End Get
        Set(ByVal value As String)
            arguements = value
        End Set
    End Property

    '
    ' Get the times 
    '
    Public Property _time() As SMTWTFS
        Get
            Return time
        End Get
        Set(ByVal value As SMTWTFS)
            time = value
        End Set

    End Property

    '
    ' Check or set if the application is enabled 
    '
    Public Property _Enabled() As Boolean
        Get
            Return Enabled
        End Get
        Set(ByVal value As Boolean)
            Enabled = value
        End Set
    End Property

    '
    ' Check or set if the application is enabled 
    '
    Public Property _StartUp() As Boolean
        Get
            Return startup
        End Get
        Set(ByVal value As Boolean)
            startup = value
        End Set
    End Property


    '
    ' Default new application 
    '
    Public Sub New(ByVal app As String, _
                           ByVal En As Boolean, _
                           ByVal arg As String, _
                           ByVal t As SMTWTFS, _
                           ByVal runAtStartUP As Boolean)


        application = app
        arguements = arg
        Enabled = En
        time = t
        shortName = "temp"
        startup = runAtStartUP
        updateShortName()
        System.GC.Collect()

    End Sub

    '
    ' Most of the processing time for this structure will be spent here. 
    '
    Public Sub updateShortName()

        Try

            '
            ' Define variables
            '
            Dim value As ATEA = Me
            Dim sN() As String
            Dim tempName As String

            '
            ' Split the application name down and set the first part to the end of the application path
            '
            sN = value.application.Split("\"c)
            If sN(sN.Count - 1) = "" Then
                tempName = value.application
            Else
                tempName = sN(sN.Count - 1)
            End If

            '
            ' Actual application name
            '
            If sN(sN.Count - 1).Length > 20 Then
                shortName = tempName.Substring(0, 19).ToLower & "..."
            Else
                shortName = tempName.ToLower
            End If

            '
            ' Arguements
            '
            If arguements <> "" Then
                If arguements.Length > 7 Then
                    shortName &= " : " & arguements.Substring(0, 5) & "..."
                Else
                    shortName &= " : " & arguements
                End If
            End If

            If startup Then

                shortName &= " @ Start up"

            Else


                '
                ' Time and Enabled
                '

                If (CDate(time.todaysTime) > CDate(Hour(Now) & ":" & Minute(Now) & ":" & Second(Now))) Then
                    If time.etodaysTime = False Then
                        shortName &= ", will NOT launch today. **"
                    Else
                        If Enabled = True Then

                            shortName &= " @ " & CDate(time.todaysTime) & " today."

                        Else
                            shortName = shortName & " is disabled! ***"
                        End If
                    End If

                Else
                    If time.etomorrowsTime = False Then
                        shortName &= " will not launch tomorrow. **"
                    Else
                        If Enabled = True Then
                            shortName &= " @ " & CDate(time.tomorrowsTime) & " tomorrow."
                        Else
                            shortName = shortName & " is disabled! ***"
                        End If
                    End If


                End If

            End If
          


        Catch
            MsgBox("There has been an error in the updateShortName function. Please visit SourceForge.net/rcktlchr to report this problem.", MsgBoxStyle.Critical, "ERROR")
            frmMain.Timer1.Stop()
        End Try


        GC.Collect()
    End Sub

End Class
